-
Notifications
You must be signed in to change notification settings - Fork 14.7k
ELF: -r: Call assignAddresses only once #152240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ELF: -r: Call assignAddresses only once #152240
Conversation
Created using spr 1.3.5-bogner
@llvm/pr-subscribers-lld @llvm/pr-subscribers-backend-risc-v Author: Fangrui Song (MaskRay) ChangesThe fixed-point layout algorithm handles linker scripts, thunks, and Since we don't scan relocations for relocatable links, the To prevent cluttering the line history, I place the Full diff: https://github.com/llvm/llvm-project/pull/152240.diff 3 Files Affected:
diff --git a/lld/ELF/Arch/LoongArch.cpp b/lld/ELF/Arch/LoongArch.cpp
index 8802c8c2e7f01..838ca4d242c7b 100644
--- a/lld/ELF/Arch/LoongArch.cpp
+++ b/lld/ELF/Arch/LoongArch.cpp
@@ -1396,9 +1396,6 @@ void LoongArch::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
// change in section sizes can have cascading effect and require another
// relaxation pass.
bool LoongArch::relaxOnce(int pass) const {
- if (ctx.arg.relocatable)
- return false;
-
if (pass == 0)
initSymbolAnchors(ctx);
diff --git a/lld/ELF/Arch/RISCV.cpp b/lld/ELF/Arch/RISCV.cpp
index 72d83159ad8ac..ba0584bb1799b 100644
--- a/lld/ELF/Arch/RISCV.cpp
+++ b/lld/ELF/Arch/RISCV.cpp
@@ -942,9 +942,6 @@ static bool relax(Ctx &ctx, int pass, InputSection &sec) {
// relaxation pass.
bool RISCV::relaxOnce(int pass) const {
llvm::TimeTraceScope timeScope("RISC-V relaxOnce");
- if (ctx.arg.relocatable)
- return false;
-
if (pass == 0)
initSymbolAnchors(ctx);
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 2b0e097766d2c..fdacc54282c2c 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1543,6 +1543,8 @@ template <class ELFT> void Writer<ELFT>::finalizeAddressDependentContent() {
uint32_t pass = 0, assignPasses = 0;
for (;;) {
+ if (ctx.arg.relocatable)
+ break;
bool changed = ctx.target->needsThunks
? tc.createThunks(pass, ctx.outputSections)
: ctx.target->relaxOnce(pass);
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Could be worth an explanatory comment "Final addresses not available in relocatable links." but I'm OK without one.
Created using spr 1.3.5-bogner
Thanks! Switched to |
The fixed-point layout algorithm handles linker scripts, thunks, and relaxOnce (to suppress out-of-range GOT-indirect-to-PC-relative optimization). These passes are not needed for relocatable links because they require address information that is not yet available. Since we don't scan relocations for relocatable links, the `createThunks` and `relaxOnce` functions are no-ops anyway, making these passes redundant. To prevent cluttering the line history, I place the `if (...) break;` inside the for loop. Pull Request: llvm/llvm-project#152240
The fixed-point layout algorithm handles linker scripts, thunks, and
relaxOnce (to suppress out-of-range GOT-indirect-to-PC-relative
optimization). These passes are not needed for relocatable links because
they require address information that is not yet available.
Since we don't scan relocations for relocatable links, the
createThunks
andrelaxOnce
functions are no-ops anyway, making thesepasses redundant.
To prevent cluttering the line history, I place the
if (...) break;
inside the for loop.